package com.beanCopy;

import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * Created by dong peng on 2020/8/12.
 */
public class MainTest {

    public static void main(String[] args) throws CloneNotSupportedException {
        UserDO userDO = new UserDO();
        userDO.setAge(18);
        userDO.setBirthDay(new Date());
        userDO.setName("张三");

        CarDO carDO = new CarDO();
        carDO.setName("宝马");
        carDO.setTypeEnum(TypeEnum.one);
        userDO.setCarDO(carDO);

        System.out.println("拷贝前" + userDO);
        UserDO userDO1 = (UserDO) userDO.clone();
        System.out.println(userDO1.getCarDO() == userDO.getCarDO());
        System.out.println("克隆后： " + userDO1);

        UserBO userBO = new UserBO();
        BeanUtils.copyProperties(userDO, userBO);
        System.out.println("拷贝后： " + userBO);

        System.out.println("深拷贝后: " + UserConvertor.userDO2BO(userDO));
    }
}
